package front

import (
	"hft/Http/Models/request/front"
	utils "hft/Http/Utils"
	"strconv"

	"github.com/gin-gonic/gin"

	frontServe "hft/Http/Services/front"
)

type Active struct{}

func (*Active) GetActiveList(c *gin.Context) {

	sid, _ := strconv.Atoi(c.Request.Header.Get("sid"))

	var data front.ActivePage

	c.ShouldBind(&data)

	list, err := frontServe.ActiveService.GetActiveList(&data, sid)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(list, c)

}

func (*Active) GetActiveInfo(c *gin.Context) {
	id, _ := strconv.Atoi(c.DefaultQuery("id", "0"))
	data, err := frontServe.ActiveService.GetActiveInfo(id)
	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}
	utils.OkWithData(data, c)
}

var ActiveController = new(Active)
